<?php
namespace app\api\model;

use think\Model;

class Banner extends  BaseModel{
    protected $hidden = ['description','delete_time','update_time']; //设置自动隐藏的字段
    public function items(){
        //banner表名关联banner_item表，
        //传参:关联模型、关联字段、本模型的主键
        return $this->hasMany('banner_item', 'banner_id', 'id');
    }

    public static function getBannerByID($id){
        $banner = self::field('*,description as des')->with(['items', 'items.img'])
                    ->find($id);
        
        return $banner;
    }
}

?>